<template>
    <div>
        <a-card>
            <h3>个人设置</h3>
            <a-form-model>
                <!-- 作者名称 -->
                <a-form-model-item label="作者名称" prop="name">
                    <a-input v-model="profile.name"></a-input>
                </a-form-model-item>
                <!-- 头像 -->
                <a-form-model-item label="头像" prop="avatar">
                    <a-input v-model="profile.avatar"></a-input>
                </a-form-model-item>
                <!-- 座右铭 -->
                <a-form-model-item label="座右铭" prop="slogan">
                    <a-input v-model="profile.slogan"></a-input>
                </a-form-model-item>
                <!-- 个人介绍 -->
                <a-form-model-item label="个人介绍" prop="desc">
                    <a-textarea v-model="profile.desc"></a-textarea>
                </a-form-model-item>
                <!-- QQ -->
                <a-form-model-item label="QQ" prop="qqchat">
                    <a-input v-model="profile.qqchat"></a-input>
                </a-form-model-item>
                <!-- 微信 -->
                <a-form-model-item label="微信" prop="wechat">
                    <a-input v-model="profile.wechat"></a-input>
                </a-form-model-item>
                <!-- bilibili -->
                <a-form-model-item label="哔哩哔哩" prop="bili">
                    <a-input v-model="profile.bili"></a-input>
                </a-form-model-item>
                <!-- 域名 -->
                <a-form-model-item label="域名" prop="domain">
                    <a-input v-model="profile.domain"></a-input>
                </a-form-model-item>
                <!-- 码云 -->
                <a-form-model-item label="码云" prop="gitee">
                    <a-input v-model="profile.gitee"></a-input>
                </a-form-model-item>
                <!-- 邮箱 -->
                <a-form-model-item label="邮箱" prop="email">
                    <a-input v-model="profile.email"></a-input>
                </a-form-model-item>
                <!-- 提示信息 -->
                <a-form-model-item label="提示信息" prop="notice">
                    <a-input v-model="profile.notice"></a-input>
                </a-form-model-item>
                <!-- 提交 -->
                <a-form-model-item>
                    <a-button
                        type="danger"
                        style="margin-right: 15px"
                        @click="updateProfile"
                        >更新</a-button
                    >
                </a-form-model-item>
            </a-form-model>
        </a-card>
    </div>
</template>
<script>
export default {
    data() {
        return {
            profile: {
                id: 1,
                name: "",
                slogan: "",
                desc: "",
                qq_chat: "",
                wechat: "",
                bili: "",
                domain: "",
                gitee: "",
                email: "",
                avatar: "",
                notice: "",
            },
        };
    },
    created() {
        this.getProfileInfo();
    },
    methods: {
        // 获取个人信息
        async getProfileInfo() {
            const { data: res } = await this.$axios.get(
                `profile/${this.profile.id}`
            );
            if (res.code !== 200) return this.$message.error(res.msg);
            this.profile = res.data.data;
        },
        // 更新
        async updateProfile() {
            const { data: res } = await this.$axios.put(
                `profile/${this.profile.id}`,
                this.profile
            );
            if (res.code !== 200) return this.$message.error(res.msg);
            this.$message.success(`个人信息更新成功`);
            this.$router.push("/index");
        },
    },
};
</script>
<style>
</style>